const express = require('express');
const expressJoi = require('@escook/express-joi');
const { expressjwt: jwt } = require('express-jwt');

const { reg_login_schema } = require('../schema/user');

const router = express.Router();

const userHandler = require('../routerHandler/user');

// router.use(jwt({
//     secret: SECRET_KEY,
//     algorithms: ['HS256']
// }).unless({
//     path: [/^\/user\/register/, /^\/user\/login/, /^\/user\/verification-code/]
// }));

router.get('/user-info', userHandler.getUserInfo);

router.post('/register', expressJoi(reg_login_schema), userHandler.register);

router.post('/login', expressJoi(reg_login_schema), userHandler.login);

router.get('/verification-code', userHandler.verificationCode);

router.post('/problem/addcount', userHandler.addCount);

router.post('/problem/subCanProblemCount', userHandler.subCanProblemCount);

module.exports = router;